<script>
export default {
  name: "AddGoods",
  methods: {
      submit(){
        const goodsName=this.$refs.goodsName.value.trim();
        const goodsPrice=this.$refs.goodsPrice.value.trim()/1;
        if(goodsName.length>0 && goodsPrice>0){
          this.$store.commit('ADD_Goods', {goodsName, goodsPrice});
        }
      }
  }
}
</script>

<template>
<div>
  <p>商品名称: <input ref="goodsName" type="text"></p>
  <p>商品价格: <input ref="goodsPrice" type="text"></p>
  <button @click="submit">提交</button>
</div>
</template>

<style scoped>

</style>